﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sustainalytics.ClientDW.Entities;
using System;

namespace Sustainalytics.GCCS.Tests
{
    [TestClass]
    public class GCPrincipleConclusionManagerTests
    {
        [TestMethod]
        public void GetByPrincipleSummary_Success()
        {
            GCPrincipleConclusion expectedValue = new GCPrincipleConclusion
            {
                Id = Guid.NewGuid()
            };

            var repo = new Sustainalytics.ClientDW.DataAccessLayer.Fakes.StubIClientDWGlobalCompactRepository
            {
                GetGCPrincipleConclusionByPrincipleSummaryGuid = (Guid principleSummaryId) =>
                    {
                        return expectedValue;
                    }
            };

            var manager = new GCPrincipleConclusionManager(repo);

            var value = manager.GetByPrincipleSummary(expectedValue.Id);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Id == expectedValue.Id, "Returned value is different than the expected value.");
        }

        [TestMethod]
        [ExpectedException(typeof(GCPrincipleConclusionNotFoundException))]
        public void GetByPrincipleSummary_NotFound_Exception()
        {
            var repo = new Sustainalytics.ClientDW.DataAccessLayer.Fakes.StubIClientDWGlobalCompactRepository
            {
                GetGCPrincipleConclusionByPrincipleSummaryGuid = (Guid principleSummaryId) =>
                {
                    return null;
                }
            };

            var manager = new GCPrincipleConclusionManager(repo);

            manager.GetByPrincipleSummary(Guid.NewGuid());
        }
    }
}
